﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/Basic.Master" AutoEventWireup="true" CodeBehind="ExportTableList.aspx.cs" Inherits="PMS.UI.BD.ExportTableList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script>
        $(function () {
            var height = $("#divTotal").height();
            var master = $("#master").height();
            var content = parseFloat(height) - parseFloat(master) - 30;
            $("#tbList").css("height", content);
        });
    </script>
    <script>

        $(function () {
            $("#tbList").datagrid({
                url: '/Logic/BD/ExportTableAjax.aspx?method=GetTableList',
                loadMsg: '数据加载中请稍后……',
                queryParams: com.serializeSearchArray("form1"),
                pagination: true,
                rownumbers: true,
                idField: "Id",
                singleSelect: true,
                pageSize: 20,
                pageList: [20, 50, 100],
                striped: true,
                frozenColumns: [[{ field: 'ck', checkbox: true, width: 30 },
                {
                    field: 'Model', title: '所属模块', align: "center", width:200,formatter: function (value, row, index) {
                        return com.getArrayText(StaticCombo.ModName, value);
                    }, editor: {
                        type: "combobox",
                        options: {
                            data: StaticCombo.ModName,
                            valueField: 'value',
                            textField: 'text',
                            required: true
                        }
                    }
                },
                 {
                     field: 'Name', title: '名称', width:240, align: "center", editor: {
                         type: "validatebox",
                         options: {
                         }
                     }
                 },
                {
                    field: 'TableName', title: '数据库表名', width:600, align: "center", editor: {
                        type: "validatebox",
                        options: {
                        }
                    }}
                ]], onAfterEdit: function (rowIndex, rowData, changes) {
                    if (editAction == "edit") {
                        com.ajax({
                            url: "/Logic/BD/ExportTableAjax.aspx?method=EditExportTableList",
                            data: rowData,
                            success: function (data) {
                                com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); });
                            }
                        });
                    } else if (editAction == "add") {
                        com.ajax({
                            url: "/Logic/BD/ExportTableAjax.aspx?method=AddExportTableList",
                            data: rowData,
                            success: function (data) {
                                com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); });
                            }
                        });
                    }
                    editRow = undefined;
                }, onCancelEdit: function (rowIndex, rowData) {
                    $("#tbList").datagrid("rejectChanges");

                }
            });
        });

    </script>

    <script>
        editRow = undefined;
        editAction = undefined;
        function funcSearch() {
            var para = com.serializeSearchArray("form1");
            $("#tbList").datagrid("load", para);

        }
        function funcAdd() {
            //添加时先判断是否有开启编辑的行，如果有则把开户编辑的那行结束编辑
            if (editRow != undefined) {

            }
            //添加时如果没有正在编辑的行，则在datagrid的第一行插入一行
            if (editRow == undefined) {
                $("#tbList").datagrid("insertRow", {
                    index: 0, // index start with 0
                    row: {

                    }
                });
                //将新插入的那一行开户编辑状态
                $("#tbList").datagrid("beginEdit", 0);
                //给当前编辑的行赋值
                editRow = 0;
                editAction = "add";
            }
        }
        function funcEdit() {
            var row = $('#tbList').datagrid('getSelected');
            if (row) {
                if (editRow != undefined) {
                }
                else {
                    var index = $("#tbList").datagrid('getRowIndex', row);
                    //   var index = row.Id;
                    $("#tbList").datagrid('beginEdit', index);
                    editAction = "edit";
                    editRow = index;
                }
            }
            else {
                com.message("information", "请选中一行");
            }
        }
        function funcRemove() {
            $.messager.confirm('确认对话框', '您确定删除该表格吗？', function (r) {
                if (r) {
                    var rowData = $("#tbList").datagrid("getSelected");
                    if (rowData) {
                        com.ajax({
                            url: '/Logic/BD/ExportTableAjax.aspx?method=DelExportTableList',
                            data: { Id: rowData.Id },
                            success: function (data) {
                                com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); })

                            }

                        });
                    }
                }
            });
        }

        function funcSave() {
            $('#tbList').datagrid('endEdit', editRow);
        }
        function funcCancel() {
            $('#tbList').datagrid("cancelEdit", editRow);
            editRow = undefined;
            editAction = undefined;
        }
        function funcReload() {
            $("#form1").form("reset");
            var para = com.serializeSearchArray("form1");
            $("#tbList").datagrid("load", para);
        }

        function funcTableSpecific() {

            var row = $('#tbList').datagrid('getSelected');
            if (row) {
                top.wrapper.addTab("查看特殊列","/UI/BD/ExportTableSpecificColumns.aspx?TotalId=" + row.Id);
            }
            else { com.message("information", "请选中一行"); }

        }

        
        function funcTableColumn() {
          
            var row = $('#tbList').datagrid('getSelected');
            if (row) {
                top.wrapper.addTab("查看列","/UI/BD/ExportTableColumns.aspx?TotalId=" + row.Id);
            }
            else { com.message("information", "请选中一行"); }

        }


    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="divTotal" style="height: 100%; width: 100%">
        <div id="master" class="container_12" style="height: auto">
            <form id="form1">
                <div class="grid_1 sealbl" style="text-align: right;">
                    名称 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input id="Name" name="Name" type="text" data-cp="co" />
                </div>
                <div class="grid_1 sealbl" style="text-align: right;">
                    数据库表 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input id="TableName" name="TableName" type="text" data-cp="co" />
                </div>
                <div class="grid_1 sealbl" style="text-align: right;">
                    所属模块 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input id="Model" name="Model" class="easyui-combobox" data-options="valueField:'value',textField:'text',data:StaticCombo.ModName,panelHeight:'auto',editable:false" data-cp="=" />
                </div>
            </form>
        </div>
        <table id="tbList" title="导出Excel表格 " style="width: 100%; height: 300px">
        </table>
    </div>
</asp:Content>
